import Vue from "vue";
import VueRouter from "vue-router";
import store from "../store/index.js";
import Home from "../views/Home.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "Home",
    component: Home,
  },
  {
    path: "/list",
    name: "list",

    component: () => import("../views/List.vue"),
  },
  {
    path: "/shopcar",
    name: "shopcar",

    component: () => import("../views/Shopcar.vue"),
  },
  {
    path: "/my",
    name: "my",

    component: () => import("../views/My.vue"),
  },
  {
    path: "/detail",
    name: "detail",

    component: () => import("../views/Detail.vue"),
  },
  {
    path: "/login",
    name: "login",

    component: () => import("../views/Login.vue"),
  },
];

const router = new VueRouter({
  routes,
});

// router.beforeEach((to, from, next) => {
//   if (store.state.user != "") {
//     next();
//   } else {
//     if (to.path == "/login") {
//       next();
//     } else {
//       next("/login");
//     }
//   }
// });

export default router;
